package com.wu.crud.controller;

import com.wu.crud.bean.SuperAdmin;
import com.wu.crud.service.SuperAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
public class SuperAdminController {
    @Autowired
    SuperAdminService superAdminService;

    /**
     * 超级管理员的登录
     * @param id
     * @param password
     * @param model
     * @return
     */
    @RequestMapping("/admin_login")
    public String selectByIdAndPassword(String id, String password, Model model){
        System.out.println("用户登录："+id);
        SuperAdmin superAdmin = superAdminService.login(id, password);
        if (superAdmin.getId() != null){
            model.addAttribute("superAdmin",superAdmin);
//        return Msg.success().add("superAdmin",superAdmin);
            return "admin_index";
        }else {
            return "admin_login";
        }

    }

    @RequestMapping("admin_index")
    public String toAdminIndex(){
        return "admin_index";
    }
}
